<template>
  <div class="home-container">
    <div style="background: #ececec; padding: 25px">
      <a-row :gutter="16">
        <a-col :span="8">
          <a-card>
            <a-statistic
              title="金额"
              :value="26000.18"
              :precision="2"
              prefix="￥"
              :value-style="{ color: '#3f8600' }"
              style="margin-right: 50px"
            >
              <!-- <template #prefix>
                <arrow-up-outlined />
              </template> -->
            </a-statistic>
          </a-card>
        </a-col>
        <a-col :span="8">
          <a-card>
            <a-statistic title="订单量" :value="50" :precision="0" style="margin-right: 50px" />
          </a-card>
        </a-col>
        <a-col :span="8">
          <a-card>
            <a-statistic
              title="用户数"
              :value="18000"
              :precision="0"
              :value-style="{ color: '#1890ff' }"
            />
          </a-card>
        </a-col>
      </a-row>
    </div>
    <div style="margin-top: 25px">
      <a-carousel
        v-if="adsList != undefined && adsList.length > 0"
        dot-position="bottom"
        autoplay
        arrows
      >
        <template #prevArrow>
          <div class="custom-slick-arrow" style="left: 10px; z-index: 1">
            <left-circle-outlined />
          </div>
        </template>
        <template #nextArrow>
          <div class="custom-slick-arrow" style="right: 10px">
            <right-circle-outlined />
          </div>
        </template>
        <div v-for="(item, index) in adsList" :key="index">
          <a :href="item.url + '/' + encodeURIComponent(href)" target="_blank"
            ><img :src="item.pic" style="width: 100%"
          /></a>
        </div>
      </a-carousel>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, onMounted, toRefs } from 'vue'
import { Statistic, Row, Col, Carousel, Image } from 'ant-design-vue'
import {
  SettingOutlined,
  EditOutlined,
  EllipsisOutlined,
  LeftCircleOutlined,
  RightCircleOutlined
} from '@ant-design/icons-vue'
import { useStore } from '@/store'

export default defineComponent({
  name: 'Workplace',
  components: {
    [Statistic.name]: Statistic,
    [Carousel.name]: Carousel,
    [Image.name]: Image,
    [Row.name]: Row,
    [Col.name]: Col,
    SettingOutlined,
    EditOutlined,
    LeftCircleOutlined,
    RightCircleOutlined,
    EllipsisOutlined
  },
  setup() {
    const userInfo = useStore().getters['user/userInfo']
    const state = reactive<any>({
      adsList: [],
      href: window.location.href
    })
    onMounted(() => {
      getAds()
    })
    function getAds() {
      ;(window as any).AdsData('4808573508839006').then((res) => {
        state.adsList = res
      })
    }
    return {
      ...toRefs(state),
      userInfo
    }
  }
})
</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  height: calc(100vh - 280px);
  display: flex;
  flex-direction: column;

  img {
    flex: 1;
    min-height: 0;
  }

  .ant-form {
    flex: 2;
  }
}
:deep(.slick-slide) {
  text-align: center;
  height: 160px;
  line-height: 160px;
  background: #364d79;
  overflow: hidden;
}

:deep(.slick-arrow.custom-slick-arrow) {
  width: 25px;
  height: 25px;
  font-size: 25px;
  color: #fff;
  background-color: rgba(31, 45, 61, 0.11);
  transition: ease all 0.3s;
  opacity: 0.3;
  z-index: 1;
}
:deep(.slick-arrow.custom-slick-arrow:before) {
  display: none;
}
:deep(.slick-arrow.custom-slick-arrow:hover) {
  color: #fff;
  opacity: 0.5;
}

:deep(.slick-slide h3) {
  color: #fff;
}
</style>
